from PySide6.QtWidgets import QToolBar
from PySide6.QtGui import QAction


class ToolBar(QToolBar):
    def __init__(self, main_window):
        super().__init__("主工具栏")
        self.main_window = main_window
        self.initUI()

    def initUI(self):
        runAction = QAction('运行', self.main_window)
        runAction.triggered.connect(self.main_window.runProcessing)
        self.addAction(runAction)

        stopAction = QAction('终止', self.main_window)
        stopAction.triggered.connect(self.main_window.stopProcessing)
        self.addAction(stopAction)

        self.addSeparator()

        copyAction = QAction('复制', self.main_window)
        copyAction.triggered.connect(self.main_window.copySelected)
        self.addAction(copyAction)

        cutAction = QAction('剪切', self.main_window)
        cutAction.triggered.connect(self.main_window.cutSelected)
        self.addAction(cutAction)

        pasteAction = QAction('粘贴', self.main_window)
        pasteAction.triggered.connect(self.main_window.pasteSelected)
        self.addAction(pasteAction)

        deleteAction = QAction('删除', self.main_window)
        deleteAction.triggered.connect(self.main_window.deleteSelected)
        self.addAction(deleteAction)

        self.addSeparator()

        zoomInAction = QAction('放大', self.main_window)
        zoomInAction.triggered.connect(self.main_window.zoomIn)
        self.addAction(zoomInAction)

        zoomOutAction = QAction('缩小', self.main_window)
        zoomOutAction.triggered.connect(self.main_window.zoomOut)
        self.addAction(zoomOutAction)

        #self.addSeparator()

        # # 添加主题切换按钮
        # lightThemeAction = QAction('白天', self.main_window)
        # lightThemeAction.triggered.connect(lambda: self.main_window.applyTheme("light"))
        # self.addAction(lightThemeAction)
        #
        # darkThemeAction = QAction('黑夜', self.main_window)
        # darkThemeAction.triggered.connect(lambda: self.main_window.applyTheme("dark"))
        # self.addAction(darkThemeAction)